
/*package com.hy.enterprise.framework.persistence.domain.query.internal ;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.util.Collection;

import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import com.hy.enterprise.framework.lang.proxy.CglibProxyFactory;
import com.hy.enterprise.framework.lang.proxy.IProxyFactory;
import com.hy.enterprise.framework.persistence.domain.query.internal.managedobjects.LibraManagedObject;
import com.hy.enterprise.framework.util.lang.AnnotationUtil;
import com.hy.enterprise.framework.util.lang.ObjectUtil;

*//**
 * <ul>
 * <li>设计作者：刘川</li>
 * <li>设计日期：2009-8-10</li>
 * <li>设计时间：下午02:42:42</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订历史</b>
 * <li>1、</li>
 * </ul>
 *//*
public class PropertyAccessRecordingInvocationHandler implements
        MethodInterceptor
{
	private final LibraPersistentObjectFactory	factory	    =
	                                                          LibraPersistentObjectFactory.INSTANCE ;

	private final IProxyFactory	               proxyFactory	=
	                                                          CglibProxyFactory.INSTANCE ;

	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-10</li>
	 * <li>设计时间：下午02:50:30</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 * 
	 * @param method
	 * @return
	 *//*
	private Class < ? > associationOrComponentType (
	                                                 Method method )
	{
		Class < ? > returnType =
		                         method
		                               .getReturnType ( ) ;
		if ( returnType
		               .isAnnotationPresent ( Entity.class )
		     || returnType
		                  .isAnnotationPresent ( Embeddable.class ) )
		{
			return returnType ;
		}
		if ( ( AnnotationUtil
		                     .getPropertyOrGetterAnnotation (
		                                                      method ,
		                                                      OneToOne.class ) != null )
		     || ( AnnotationUtil
		                        .getPropertyOrGetterAnnotation (
		                                                         method ,
		                                                         ManyToOne.class ) != null ) )
		{
			return returnType ;
		}
		return null ;
	}

	*//**
	 * <ul>
	 * <li>设计作者：刘川</li>
	 * <li>设计日期：2009-8-10</li>
	 * <li>设计时间：下午02:46:55</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订历史</b>
	 * <li>1、</li>
	 * </ul>
	 * 
	 * @param method
	 * @return
	 *//*
	private Class < ? > collectionElementType (
	                                            Method method )
	{
		if ( ! Collection.class
		                       .isAssignableFrom ( method
		                                                 .getReturnType ( ) ) )
		{
			return null ;
		}

		OneToMany oneToMany =
		                      AnnotationUtil
		                                    .getPropertyOrGetterAnnotation (
		                                                                     method ,
		                                                                     OneToMany.class ) ;
		ManyToMany manyToMany =
		                        AnnotationUtil
		                                      .getPropertyOrGetterAnnotation (
		                                                                       method ,
		                                                                       ManyToMany.class ) ;

		if ( ( oneToMany == null )
		     && ( manyToMany == null ) )
		{
			throw new IllegalStateException (
			                                  "方法：["
			                                          + method
			                                          + "]并非用于处理持久化集合" ) ;
		}

		if ( ( oneToMany != null )
		     && ! void.class
		                    .equals ( oneToMany
		                                       .targetEntity ( ) ) )
		{
			return oneToMany
			                .targetEntity ( ) ;
		}
		if ( ( manyToMany != null )
		     && ! void.class
		                    .equals ( manyToMany
		                                        .targetEntity ( ) ) )
		{
			return manyToMany
			                 .targetEntity ( ) ;
		}
		ParameterizedType parameterizedType =
		                                      ( ParameterizedType ) method
		                                                                  .getGenericReturnType ( ) ;
		return ( Class < ? > ) parameterizedType
		                                        .getActualTypeArguments ( ) [ 0 ] ;
	}

	*//**
	 * @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object,
	 *      java.lang.reflect.Method, java.lang.Object[],
	 *      net.sf.cglib.proxy.MethodProxy)
	 *//*
	@ SuppressWarnings ( "unchecked" )
	public Object intercept (
	                          Object proxy ,
	                          Method method ,
	                          Object [ ] args ,
	                          MethodProxy methodProxy )
	                                                   throws Throwable
	{

		if ( ! ObjectUtil
		                 .isGetter ( method ) )
		{
			return methodProxy
			                  .invokeSuper (
			                                 proxy ,
			                                 args ) ;
		}
		String propertyName =
		                      ObjectUtil
		                                .propertyNameForGetter ( method ) ;
		LibraManagedObject about =
		                           AliasFactory
		                                       .about ( proxy ) ;

		String fullyQualifiedPtyName =
		                               about
		                                    .getPreferredStringRepresentation ( )
		                                       + "."
		                                       + propertyName ;

		Class propertyClass =
		                      this
		                          .associationOrComponentType ( method ) ;
		Class collectionElement =
		                          this
		                              .collectionElementType ( method ) ;

		Object ret =
		             null ;

		if ( propertyClass == null )
		{
			ret =
			      this.factory
			                  .makeNew ( method
			                                   .getReturnType ( ) ) ;
		}
		else
		{
			ret =
			      this.proxyFactory
			                       .createProxy (
			                                      proxy
			                                           .getClass ( )
			                                           .getClassLoader ( ) ,
			                                      this ,
			                                      propertyClass ) ;
		}

		if ( collectionElement != null )
		{
			Object elementProxy =
			                      this.proxyFactory
			                                       .createProxy (
			                                                      proxy
			                                                           .getClass ( )
			                                                           .getClassLoader ( ) ,
			                                                      this ,
			                                                      collectionElement ) ;
			AliasFactory
			            .rememberAsCollectionAssociationPath (
			                                                   ret ,
			                                                   fullyQualifiedPtyName ,
			                                                   collectionElement ,
			                                                   elementProxy ) ;
		}
		else
		{
			AliasFactory
			            .rememberAsAssociationPath (
			                                         ret ,
			                                         fullyQualifiedPtyName ) ;
		}
		return ret ;
	}
}*/
